package com.four.seckill.mq;


import com.four.seckill.dao.SeckillMapper;
import com.four.seckill.service.ISeckillService;
import com.four.seckill.vo.SeckillVo3;
import com.guli.common.utils.R;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "shop")
public class Consumer {


    @Autowired
    private ISeckillService pmsSeckillProductService;

    /**
     * 消费者监听秒杀任务队列，然后执行秒杀
     * @param seckillVo
     */
    @RabbitHandler
    public void seckeillconsumer(SeckillVo3 seckillVo){

        R userseckillgoods = pmsSeckillProductService.userseckillgoods(seckillVo.getSeId(),seckillVo.getUserName());
        /**
         * 控制台打印秒杀记录
         */
        System.out.println(userseckillgoods.get("ok"));
    }

}
